package com.code.springboot3.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.code.springboot3.model.dto.AddArticleDto;
import com.code.springboot3.model.dto.UpdateArticleDto;
import com.code.springboot3.model.entity.Article;
import jakarta.servlet.http.HttpServletRequest;


/**
* @author Soft
* @description 针对表【article】的数据库操作Service
* @createDate 2024-12-26 15:38:06
*/
public interface ArticleService extends IService<Article> {

    Article getArticleDetail(Integer id, HttpServletRequest request);

    /**
     * 新增文章
     * @param addArticleDto
     * {
     *   "title": "陕西旅游攻略",
     *   "content": "兵马俑,华清池,法门寺,华山...爱去哪去哪...",
     *   "coverImg": "https://big-event-gwd.oss-cn-beijing.aliyuncs.com/9bf1cf5b-1420-4c1b-91ad-e0f4631cbed4.png",
     *   "state": "草稿",
     *   "categoryId": 2
     * }
     * @param token 令牌
     */
    void addCategory(AddArticleDto addArticleDto, String token);

    /**
     *
     * @param updateArticleDto ```json
     * {
     *     "id":4,
     *     "title": "北京旅游攻略",
     *     "content": "天安门,颐和园,鸟巢,长城...爱去哪去哪...",
     *     "coverImg": "https://big-event-gwd.oss-cn-beijing.aliyuncs.com/9bf1cf5b-1420-4c1b-91ad-e0f4631cbed4.png",
     *     "state": "已发布",
     *     "categoryId": 2
     * }
     * ```
     * @param token token 令牌
     * @return 1/0
     */
    Integer updateArticleDetail(UpdateArticleDto updateArticleDto, String token);

    /**
     * 删除文章
     * @param id 文章ID
     * @param token 用户token
     * @throws BusinessException 当文章不存在或无权限时抛出
     */
    void deleteArticle(Integer id, String token);
}
